/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author hellwolf
 */
@Entity
@Table(name = "inmueble")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Inmueble.findAll", query = "SELECT i FROM Inmueble i"),
    @NamedQuery(name = "Inmueble.findById", query = "SELECT i FROM Inmueble i WHERE i.id = :id"),
    @NamedQuery(name = "Inmueble.findByImporte", query = "SELECT i FROM Inmueble i WHERE i.importe = :importe"),
    @NamedQuery(name = "Inmueble.findByTelefono", query = "SELECT i FROM Inmueble i WHERE i.telefono = :telefono"),
    @NamedQuery(name = "Inmueble.findByMetrosCuadrados", query = "SELECT i FROM Inmueble i WHERE i.metrosCuadrados = :metrosCuadrados"),
    @NamedQuery(name = "Inmueble.findByCalle", query = "SELECT i FROM Inmueble i WHERE i.calle = :calle")})
public class Inmueble implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Importe")
    private Float importe;
    @Column(name = "telefono")
    private String telefono;
    @Column(name = "metrosCuadrados")
    private Float metrosCuadrados;
    @Column(name = "calle")
    private String calle;
    @JoinColumn(name = "DNINIF", referencedColumnName = "cif")
    @ManyToOne
    private Cliente dninif;

    public Inmueble() {
    }

    public Inmueble(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public Float getImporte() {
        return importe;
    }

    public void setImporte(Float importe) {
        Float oldImporte = this.importe;
        this.importe = importe;
        changeSupport.firePropertyChange("importe", oldImporte, importe);
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        String oldTelefono = this.telefono;
        this.telefono = telefono;
        changeSupport.firePropertyChange("telefono", oldTelefono, telefono);
    }

    public Float getMetrosCuadrados() {
        return metrosCuadrados;
    }

    public void setMetrosCuadrados(Float metrosCuadrados) {
        Float oldMetrosCuadrados = this.metrosCuadrados;
        this.metrosCuadrados = metrosCuadrados;
        changeSupport.firePropertyChange("metrosCuadrados", oldMetrosCuadrados, metrosCuadrados);
    }

    public String getCalle() {
        return calle;
    }

    public void setCalle(String calle) {
        String oldCalle = this.calle;
        this.calle = calle;
        changeSupport.firePropertyChange("calle", oldCalle, calle);
    }

    public Cliente getDninif() {
        return dninif;
    }

    public void setDninif(Cliente dninif) {
        Cliente oldDninif = this.dninif;
        this.dninif = dninif;
        changeSupport.firePropertyChange("dninif", oldDninif, dninif);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Inmueble)) {
            return false;
        }
        Inmueble other = (Inmueble) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Inmueble[ id=" + id + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
